import Css from './css-tp.mjs'

const keys = Object.keys(Css.numVal).join('|')
const rex = new RegExp(`(${keys})(\\d+)([v])?`,'g')

// console.log(Css.numVal);
// console.log(rex);

let str = 'W50 H30 TS30 PL50 w45 TW700 W50v'

let arr = str.match(rex)
let css = arr.join('\n').replace(rex, (name, key, val, unit) => {
    let skey = Css.numVal[key]
    let sunit = unit ? Css.unit[unit] : 'px' 
    if (/(TW)/.test(key)) {
        return `.${name}{${skey}:${val};}`
    } else {
        return `.${name}{${skey}:${val}${sunit};}`
    }
})


console.log(css);